package com.yzt.minemodule.activity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.yzt.minemodule.adapter.OrderDetailItemAdapter;
import com.yzt.zhuju.network.AresSubscriber;
import com.yzt.zhuju.network.biz.BizLayer;
import com.yzt.zhuju.network.entity.mine.wallet.WalletBean;
import com.yzt.minemodule.R;

import com.yzt.zhuju.mvp.MVPActivity;

/**
 * 作者：bobwang
 * 创建时间：2023-06-13 00:16:33
 * 描述：账单详情
 */
@SuppressLint({"NonConstantResourceId", "SetTextI18n"})
public class WalletDetailActivity extends MVPActivity {

    TextView tv_title;

    TextView tv_money;

    private String extraId;

    public static void startSelf(Context activity, String extraId) {
        activity.startActivity(new Intent(activity, WalletDetailActivity.class)
                .putExtra("extra_id", extraId));
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_wallet_detail;
    }

    @Override
    public void installViews() {
        extraId = getIntent().getStringExtra("extra_id");
        tv_title = findViewById(R.id.tv_title);
        tv_money = findViewById(R.id.tv_money);
        initRecycle();
        getDetail(extraId);
    }

    private OrderDetailItemAdapter adapter;

    private void initRecycle() {
        RecyclerView recyclerView = findViewById(R.id.recycler_view);
        adapter = new OrderDetailItemAdapter();
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setAdapter(adapter);
    }

    private void getDetail(String extraId) {
        BizLayer.getInstance().getMineModule().getWalletDetail(extraId, new AresSubscriber<WalletBean>() {
            @Override
            protected void onSuccess(WalletBean data) {
                mTitleBar.setTitle("");
                tv_title.setText(data.getTitle());
                tv_money.setText(data.getAmount());
                if (data.getActivityId() != null) {
                    mTitleBar.setRightContent("活动详情");
                    mTitleBar.setRightBtnListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            showToast("跳转活动详情");
                        }
                    });
                }
            }

            @Override
            protected void onFinallyEnd() {
                super.onFinallyEnd();
                closeProgress();
            }
        });
    }

    /**
     * 内容类型 [ 1：提现(审核中)，2：提现，3：场地使用费，4：提现(入账中)，5：提现(已驳回)，6：充值，7：场地使用费，8：收礼物，9：收红包，10：活动收益 ]
     */
    private String title(int type) {
        String title;
        if (type == 1) {
            title = "提现(审核中)";
        } else if (type == 2) {
            title = "提现";
        } else if (type == 3) {
            title = "场地使用费";
        } else if (type == 4) {
            title = "提现(入账中)";
        } else if (type == 5) {
            title = "提现(已驳回)";
        } else if (type == 6) {
            title = "充值";
        } else if (type == 7) {
            title = "场地使用费";
        } else if (type == 8) {
            title = "收礼物";
        } else if (type == 9) {
            title = "收红包";
        } else {
            title = "活动收益";
        }
        return title;
    }
}